home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d12
/
jaz_clib.arc
/
COPYFILE.DMO
< prev
next >
Wrap
Text File
|
1989-04-09
|
1KB
|
59 lines
/*
┌────────────────────────────────────────────────────────────────────────────┐
│copyfile.dmo │
│Copy a file to another file. Use the command line for the file names │
│Synopsis: │
│ Copyfile <source> <destin> <Options> │
│ │
└────────────────────────────────────────────────────────────────────────────┘
*/
#define BUFSIZE 32767
#if DEBUG
int wsource,wdestin;
char *wbuf,*malloc();
int wnum;
#endif
main(argc,argv)
int argc;
char **argv;
{
#if ! DEBUG
int wsource,wdestin;
char *wbuf,*malloc();
int wnum;
#endif
if ((wbuf = malloc(BUFSIZE)) == 0) {
printf("\nUnable to allocate memory for copy");
exit(1);
}
if (argc < 3) {
printf("\nUsage COPYFILE <source> <destin> <options>");
exit(1);
}
wsource = jzopnfil(argv[1],0);
wdestin = jzcrtfil(argv[2],0);
if ((wsource == -1) || (wdestin == -1)) {
printf("\nError on Open/Create File. Aborting...");
exit(1);
}
do {
wnum = jzredfil(wsource,wbuf,BUFSIZE); /* read into buffer */
if (wnum)
jzwrtfil(wdestin,wbuf,wnum); /* write only the number read */
} while (wnum);
jzclsfil(wdestin);
jzclsfil(wsource);
}